import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TCrossTowerConfig } from "../../../Message/Db/Tables/TCrossTowerConfig";
import { BossConfig } from "./BossConfig";
type int = number;
//class CrossTowerConfig
    
    export  class CrossTowerConfig
    {
        constructor()
        {
            
            this.crossTowerDic = new Map<any, any> /* flash.utils.Dictionary */();
            if (CrossTowerConfig._instance) 
            {
                throw new Error("CrossTowerConfig is singleton");
            }
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_cross_tower_config.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc1 of loc5) 
            {
                loc2 = new TCrossTowerConfig();
                loc2.copyCode = loc1.copyCode;
                loc2.spaceId = loc1.spaceId;
                loc2.floor = loc1.floor;
                loc2.killBossId = loc1.killBossId;
                loc2.bossNum = loc1.bossNum;
                loc2.name = loc1.name;
                loc2.context = loc1.context;
                loc3 = loc2.copyCode + "_" + loc2.spaceId;
                this.crossTowerDic[loc3] = loc2;
            }
            return;
        }

        public getConfig(arg1: int, arg2: int): TCrossTowerConfig
        {
            return this.crossTowerDic[arg1 + "_" + arg2];
        }

        public getBossList(arg1: TCrossTowerConfig): Array<any>
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            var loc1=[];
            if (arg1) 
            {
                loc2 = arg1.killBossId.split("#");
                loc3 = loc2.length;
                loc6 = 0;
                while (loc6 < loc3) 
                {
                    loc5 = parseInt(loc2[loc6]);
                    if ((loc4 = BossConfig.instance.getInfoByName(loc5)) != null) 
                    {
                        loc1.push(loc4);
                    }
                    ++loc6;
                }
            }
            return loc1;
        }

        public static get instance(): CrossTowerConfig
        {
            if (!CrossTowerConfig._instance) 
            {
                CrossTowerConfig._instance = new CrossTowerConfig();
            }
            return CrossTowerConfig._instance;
        }

        /* internal */ /* var */crossTowerDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: CrossTowerConfig;
    }
